﻿using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BS_2.Class
{
    class ByteHelper
    {
        public static void ByteFile(byte[] bt ,string savepath)
        {
            if (System.IO.File.Exists(savepath))
            {
                System.IO.File.Delete(savepath);
            }
            FileStream fs = new FileStream(savepath, FileMode.Create);
            BinaryWriter bw = new BinaryWriter(fs);
            bw.Write(bt, 0, bt.Length);
            fs.Close();
            bw.Close();
        }
        public static void ZipTOFile(string path)
        {
            string path1 = path + ".extract";
            if (System.IO.File.Exists(path1))
            {
                System.IO.File.Delete(path1);
            }
            ZipFile.ExtractToDirectory(path, path1);//将文件解压
            
        }
        public static void clearFolder(string FolderName)
        {
            DirectoryInfo dir = new DirectoryInfo(FolderName);

            foreach (FileInfo fi in dir.GetFiles())
            {
                fi.Delete();
            }

            foreach (DirectoryInfo di in dir.GetDirectories())
            {
                clearFolder(di.FullName);
                di.Delete();
            }
        }

    }
}
